Table of Contents

Challenge

In this reading, your challenge is to understand how and when to model systems that have more than one independent energy storage process or element.

What does this mean? Consider the following electrical circuit:

image.png

Let's imagine that you were interested in the voltage $V_{3g}$ as our dependent variable. Scoping the system and applying conservation of energy to each element, each loop, and node 2 results in the following equations:

node $$i_1 = i_2+i_3$$ loop $$V_{1g} = V_{12}+V_{2g}$$ $$V_{2g} = V_{23}+V_{3g}$$ $$V_{1g} = V_{12}+V_{23}+V_{3g}$$ element $$i_2 = C_1\dot{V}_{2g}$$ $$i_3 = C_2\dot{V}_{3g}$$ $$V_{12} = i_1R_1$$ $$V_{23} = i_3R_3$$

Now, using the tools you have built throughout this course, you know that both $C_1$ and $C_2$ store energy. In fact, you specifically know that $E_{C1}=\frac{1}{2}C_1 V_{2g}^2$ and $E_{C2}=\frac{1}{2}C_2 V_{3g}^2$. You might expect, as was the case in Reading 9, that you could end up somehow writing the energy stored in $C_1$ using voltage $V_3$ so that you could get an equation for your model that looks like:

$$\dot{V}_{3g} = \square V_{3g} + \square V_{s}$$

Or maybe as in Reading 15, where one wheel of the truck was considered the "input" and thus its stored energy was irrelevant, perhaps the voltage in $C_1$ is fully dictated by the voltage source $V_s$. Unfortunately, neither of these helpful simplifications is possible.

Following the idea that we want to eliminate all variables except for our dependent variable ${V}_3$, its derivative(s), and our independent variables (including the source voltage $V_s$), we begin to make substitutions, letting the process show us what we need to do to construct our model.

First, let's begin with the node equation, substituting in the two capacitor equations for the currents $i_1$ and $i_3$, along with the resistor equation to replace $i_1$ with voltages and resistances. That leads to the following:

$$\frac{1}{R_1}(V_s-V_{2g}) = C_1 \dot{V}_{2g} + C_2 \dot{V}_{3g}$$

This now has our output derivative $\dot{V}_{3g}$ and our input $V_s$ in it... however, we still need to eliminate the variable $V_{2g}$ and its derivative from the equation. To do this, we have access to the loop equation $V_{2g} = V_{23} + V_{3g}$. We could attempt to use this, along with the equation for resistor 2, to get an equation for $V_{2g}$, allowing us to substitute in and eliminate $V_{2}$ from our model. That looks like this:

$$V_{2g} = i_3R_2 + V_{3g}$$

We can then replace $i_3$ using the equation for $C_2$:

$$V_{2g} = R_2C_2\dot{V}_{3g} + V_{3g}$$

Great... that leads to the following updated model:

$$\frac{1}{R_1}(V_s-R_2C_2\dot{V}_{3g} + V_{3g}) = C_1 \dot{V}_{2g} + C_2 \dot{V}_{3g}$$

But the problem is that $\dot{V}_{2g}$ is still in our model!! To get rid of this, and replace it with only $V_{3g}$ and/or $V_s$ terms, we have to take the derivative of our equation for $V_{2g}$. This leads to the following expression for $\dot{V}_{2g}$:

$$\dot{V}_{2g} = R_2C_2\ddot{V}_{3g} + \dot{V}_{3g}$$

Making this substitution into our original model, we find that we have the second derivative of our output in the model! Our model ends up looking like the following:

$$\frac{1}{R_1}(V_s-R_2C_2\dot{V}_{3g} + V_{3g}) = C_1 ( R_2C_2\ddot{V}_{3g} + \dot{V}_{3g}) + C_2 \dot{V}_{3g}$$

This could be rearranged and rewritten so as to solve for the second derivative of our output:

$$\ddot{V}_{3g} = \frac{1}{R_1C_1R_2C_2}(V_s - (R_1C_1+R_2C_2)\dot{V}_{3g} -V_{3g})$$

This does satisfy our original requirements... sort of. It only contains dependent and independent variables, so in theory it is a suitable model, but the fact that it contains a second derivative as well as a first derivative and the output itself is different than what we've dealt with in the past.

Challenge Questions:

We've never seen this before, so this strange-looking model presents new questions:

  1. How can we recognize systems that will need a second (or third, fourth, fifth) derivative in order to complete a model?
  2. How can we simulate systems represented by higher-order (2 derivatives or more) differential equations?

In the following sections, we will address these questions in order. We saw that in this example, we needed two derivatives. This is because each of our capacitors stored energy independently, meaning that we had to mathematically account for energy changing in each one (even though we ended up eliminating $V_{2g}$ from our final model, since it was not our output). We could not eliminate the effects of $C_2$ storing energy or combine those effects with the energy storage in $C_1$.

To recognize systems that need more than one derivative, we first need to understand what it means to have more than one independent energy storing element in our system scope.

Independent Energy Storage Elements and System Order

In a lumped-element model of an engineering system (such as those we have been building, where each element in the system scope either stores or dissipates energy), the number of significant, independent energy storage elements is equal to the number of derivatives required to model the system.

For example, a single differential equation representing a model of a system that has 3 different energy storing elements would need to have a triple derivative of the output, a double derivative of the output, and a single derivative of the output in the equation in order to fully describe the system behavior. This is because each derivative is a representation of how the energy in the total system (consisting of 3 energy storage elements) can change.

Note: recall that all "real" systems have effectively infinite numbers of energy-storing elements. The question is never how many energy-storing elements a system truly has, but always how many of those are significant enough to include in our model.

Dependence and Independence of Energy Storage Elements

Two elements in a system model are independent of one another if the energy stored in one element cannot be directly written as a function of the energy in another. Two or more elements are dependent when Their energy storage equations can be directly related. This often occurs if the two elements are directly in series or directly in parallel in an equivalent circuit representation, and in some cases when two energy storing elements are connected by a transducer with no dissipative elements in between them.

Consider the following two systems, (a) and (b):

image.png

System (a)

In system (a), it is possible to write the energy stored in the mass as $E_m = \frac{1}{2} mv^2$, and the energy stored in the rotational inertia $J$ as $E_J = \frac{1}{2} J \Omega^2$. Because the two elements seem to store energy using different across-type variables $v$ and $\Omega$, it may be tempting to say that the two are independent. However, Because the mass and inertia are connected by a pulley, which we might assume has no slip at the contact point, we could write that $v = \Omega r$, which means that we could write that $E_m = \frac{1}{2r^2} m \Omega^2$. This would allow us to write the energy in $m$ as a function of the energy in $J$ using a common power variable, and then write one energy equation in terms of the other. In this case, we can do this by solving each energy storage equation for $\Omega^2$, obtaining:

$$\Omega^2 = \frac{2}{J}E_J = \frac{2r^2}{m}E_m$$

This means we could write the energy in the mass as a function of the energy in the inertia and parameters only, or vice versa. Each is simply a scaled version of the other.

Thus, the mass and the inertia are not independent.

In an equivalent circuit representation of system (a), we would draw a transducer linking $J$ to $m$. This means that connecting two energy storing elements directly with a transducer does not necessarily make them independent. In particular, the pulley transducer in system (a) relate velocity (A-type) to angular velocity (A-type), and both a mass and a rotational inertia store energy in their A-type power variable. This is what allowed us to write the relationship between the two energy equations. Some transducer configurations will not satisfy these conditions, so care must be taken when applying the test for independence to a system.

System (b)

In system (b), note that the connector pipe between the two tanks, both of which store energy in pressure, is assumed to have no significant resistance. With this assumption, it is easy to see that the pressures at the bottom of each tank will be the same. That means that we could define $P_{2a} = P_{3a} = P_{ta}$. Then, we could write $E_{C1} = \frac{1}{2}C_1 P_{ta}^2$ and $E_{C2} = \frac{1}{2} C_2 P_{ta}^2$. Solving for $P_{ta}^2$ in each equation would again allow us to write $E_{C1}$ as a function only of system properties and $E_{C2}$. Thus the two tanks are not independent..

Drawing an equivalent circuit for this system would show that the two "capacitors" are in parallel with one another. In fact, energy storing elements in an equivalent circuit that are either directly in series or directly in parallel are not independent of one another.

Functionally, dependent elements end up becoming "lumped" into one effective source of energy storage in our model.

In contrast with systems (a) and (b), consider system (c) below:

image.png

System (c)

For system (c), we could write the energy stored in $J_1$ as $E_{J1} = \frac{1}{2} J \Omega_1^2$ and $E_{J2} = \frac{1}{2}J_2 \Omega_2^2$.

Unlike in Systems (a) and (b), the two inertias do not move together, and there is no way to know what the value of $\Omega_2$ is just by knowing $\Omega_1$, because there is a damper in between them that dissipates a variable amount of energy depending on the difference between the two angular velocities. $\Omega_2$ is not equal to $\Omega_1$ and they can not be related with a simple constant.

Because $J_1$ stores energy in the power variable $\Omega_1$, and $J_2$ stores energy in the power variable $\Omega_2$, and because we cannot relate those two angular velocities directly without building our full model inclusive of the dissipative element $b$, the two inertias are independent. This means that a model of this system would need to include two derivatives.

Now that we have some idea of when our algebraic manipulations will lead us to a model that has more than one derivative, we need to discuss how we could possibly simulate such a model, since our current tool, Euler integration, can only simulate first order differential equations, or those with only one derivative.

Simulating Second Order Differential Equations using Euler Integration

To simulate a second order differential equation using Euler integration, consider how we thought of Euler integration in Reading 6. Computing the integral of a function was visualized as a process of repeated linear extrapolation over small timesteps.

If we consider a system model that is a second order differential equation that takes the form:

$$\ddot{y} = f(\dot{y},y,u)$$

where $u$ is our system's input, $y$ is our system's output, and "$f$" represents our model equation relating $\ddot{y}$ to $\dot{y}$ and $y$ and $u$, numerically integrating our function for $\ddot{y}$ could be used to produce an estimate of $\dot{y}$. Then, numerically integrating $\dot{y}$ one more time could be used to produce an estimate of $y$.

This process of integrating $\ddot{y}$ once, then another time, to produce our final estimate of our model's output is attractive, and could be represented by the figure below, in which $\ddot{y}(k-1)$ is used to extrapolate an estimate for $\dot{y}$, and $\dot{y}(k-1)$ is used to extrapolate an estimate for $y(k)$.

image.png

The difficulty with this approach is that $\ddot{y}$ depends on our last estimate of $\dot{y}$, $\dot{y}(k-1)$ as well as our last estimate of $y$, $y(k-1)$ and our last input $u(k-1)$. This means that the two integration operations have to occur in the same loop. The structure of such a loop can be summarized as follows, where yd represents $\dot{y}$ and ydd represents $\ddot{y}$:

for k=2:length(t)
    % compute second derivative of output based on model equation, represented here by "f."
    ydd(k-1) = f(yd(k-1),y(k-1),u(k-1));
    % now extrapolate once to get our new estimate of the first derivative of y
    yd(k) = yd(k-1) + (t(k)-t(k-1))*ydd(k-1);
    % now extrapolate a second time to get our new estimate of y itself.
    y(k) = y(k-1) + (t(k)-t(k-1))*yd(k-1);
end

Notice that we are are not using the new estimate of $\dot{y}$ in the second integration! See the figure above to see why-- we are calculating the slope of each function one timestep behind where we would like to predict to.

Also note that for this approach to work, an initial condition for $y$ is needed along with an initial condition for $\dot{y}$ so that the values y(1) and yd(1) are known, and can be used as the starting point for extrapolation on the first iteration of the loop.

Now, we have a complete set of tools we can use to deal with models with two energy storing elements. Extending the integration methodology above to include systems with even higher order derivatives also works, as long as the model equation is solved for the highest derivative. Then, the loop structure presented above can be modified to perform as many sequential integrations as is necessary.

Let's use everything we know to build and validate a model for an electrical circuit with two independent energy-storing elements.

Assignment

In this assignment, you will build a model for the following electrical circuit. In practice, a circuit like this one could be used to filter a time-varying voltage source $V_s$ (perhaps it comes from a sensor on a robot, or the output of an instrument). An analogous mechanical system might represent two masses connected by a damper to one another, with damping between ground and the second mass. In a fluid system, a similar network might represent a chemical mixing plant used to create a food or drug product, where two tanks are connected by a valve.

In this particular incarnation, we will literally model a simple electrical circuit built on a breadboard, with voltages measured by an Arduino microcontroller. The actual, physical setup is shown below:

image.png

A circuit diagram representing how the various components are connected is shown below:

image.png

What you know

In this system, the following components were used:

Deliverable: Scope and construct a model for the system

In the markdown cell below, construct a model that considers the voltage across $C_2$ to be the model's output. Your model should be a second-order differential equation that is solved for the second derivative of the output voltage.

YOUR ANSWER HERE

Deliverable: Evaluate your model

Using the data file reading17data_C2.txt in which columns are time and voltage across $C_2$, confirm that your model produces a reasonable voltage estimate.

Develop your Euler simulation below. On a single plot, compare your Euler simulation with the data.

Deliverable: Discussion

Given what you see in your Euler code vs. your block diagram simulation results, comment on the accuracy of your model. No model is perfect, so use the evaluation tools you have to determine whether the model parameters could be improved, whether your model equation is a likely source of error, or whether your Euler integration code is suspect.

Also comment on the differences in shape you notice between this plot and the similar, first-order plots we have seen for other models this semester.

YOUR ANSWER HERE